package com.ssy.lingxi.platform.manage.controller.content;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.entity.content.ContentNotice;
import com.ssy.lingxi.platform.manage.entity.content.MaterialLibrary;
import com.ssy.lingxi.platform.manage.model.request.content.*;
import com.ssy.lingxi.platform.manage.repository.MaterialLibraryRepository;
import com.ssy.lingxi.platform.manage.service.content.IMaterialLibraryService;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @menu 素材库管理
 * @author xiechenhui
 * @version 2.0.0
 * @date 2022/03/24
 */
@Api(tags = "素材库管理")
@RestController
@RequestMapping("/manage/material/library")
public class MaterialLibraryController extends BaseController {

    @Resource
    private IMaterialLibraryService materialLibraryService;

    /**
     * 素材管理分页列表
     * @param request   参数
     * @return
     */
    @PostMapping(value="/page")
    public Wrapper<PageData<MaterialLibrary>> page(@Valid @RequestBody MaterialLibraryPageRequest request) {
        return materialLibraryService.page(request, getSysUser());
    }

    /**
     * 新增素材
     * @param request 请求参数
     * @return 操作结果
     */
    @PostMapping(value = "/add")
    public Wrapper<Void> add(@Valid @RequestBody MaterialLibraryAddRequest request) {
        return materialLibraryService.add(request, getSysUser());
    }

    /**
     * 删除素材
     * @param request    素材id
     * @return 操作结果
     */
    @PostMapping(value = "/del")
    public Wrapper<Void> del(@Valid @RequestBody MaterialLibraryDelRequest request) {
        return materialLibraryService.del(request, getSysUser());
    }

    /**
     * 批量删除素材
     * @param request    素材id集合
     * @return 操作结果
     */
    @PostMapping(value = "/batchDel")
    public Wrapper<Void> batchDel(@Valid @RequestBody MaterialLibraryBatchDelRequest request) {
        return materialLibraryService.batchDel(request, getSysUser());
    }
}
